<template>
  <el-dialog :title="`${form.fid ? '修改' : '添加'}防火分区`" :visible.sync="show" :close-on-click-modal="false" :show-close="!btnLoading" width="500px" @closed="$refs.form.resetFields()">
    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
      <el-form-item prop="fid" class="hide" />
      <el-form-item prop="cfcurprojectid" class="hide" />
      <el-form-item prop="parentId" class="hide" />
      <el-form-item prop="publicareatype" class="hide" />
      <el-form-item label="工程编码" prop="fnumber"><el-input v-model.trim="form.fnumber" placeholder="请输入工程编码" :maxlength="50" /></el-form-item>
      <el-form-item label="工程名称" prop="fnameL2"><el-input v-model.trim="form.fnameL2" placeholder="请输入工程名称" :maxlength="100" /></el-form-item>
      <el-form-item label="占地面积（㎡）" prop="fbuildingterraarea"><el-input-number v-model="form.fbuildingterraarea" :min="0" :max="1e6" :precision="2" :controls="false" style="width: 100%" /></el-form-item>
    </el-form>
    <div slot="footer">
      <el-button type="primary" :loading="btnLoading" @click="btnSubmit">确 定</el-button>
      <el-button :disabled="btnLoading" @click="show = false">取 消</el-button>
    </div>
  </el-dialog>
</template>
<script>
// 添加或修改防火分区
import { nameRule } from '@/utils/validate'
import { editFormMixin } from '@/utils/mixin'
import { addBuildingManage, updateBuildingManage } from '@/api/baseManage/buildingManage'
export default {
  mixins: [editFormMixin],
  data() {
    return {
      primaryKey: 'fid',
      addApi: addBuildingManage,
      updateApi: updateBuildingManage,
      form: {
        fid: '',
        cfcurprojectid: '',
        parentId: '',
        publicareatype: 5, // 防火分区为5
        fnumber: '',
        fnameL2: '',
        fbuildingterraarea: 0
      },
      rules: {
        fnumber: [{ required: true, message: '请输入工程编码' }, nameRule],
        fnameL2: [{ required: true, message: '请输入工程名称' }, nameRule]
      }
    }
  }
}
</script>
